<?php
// +----------------------------------------------------------------------
// | 中犇单商户
// +----------------------------------------------------------------------
// | Copyright (c) 2019-2021 中犇科技 All rights reserved.
// +----------------------------------------------------------------------

namespace app\user\export;

use app\common\traits\controller\Export;
use app\user\model\Withdraw as WithdrawModel;

class WithdrawExport
{
    use Export;
    /**
     * 会员主表列表
     * @author 似水星辰 [2630481389@qq.com]
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function export($map)
    {
        // 数据列表
        $list = WithdrawModel::getList($map, [], true);
        $excelData = $_excelData = [];
        foreach ($list as $v) {
            $excelData[] = [
                'true_name' => $v['true_name'],
                'account_type' => $this->account_type($v['account_type']),
                'account_id' => $v['account_id'],
                'qrcode' => $v['qrcode'],
                'cash_fee' => $v['cash_fee'],
                'handling_fee' => $v['handling_fee'],
                'pay_fee' => $v['pay_fee'],
                'create_time' => $v['create_time'],
                'check_status' => $this->check_status($v['check_status']),
                'check_time' => $v['check_time'],
                'check_reason' => $v['check_reason'],
                'cash_status' => $this->cash_status($v['cash_status']),
                'cash_time' => $v['cash_time'],
            ];
        }
        $_excelData[0]['list'] = $excelData;
        $xlsName = lang('提现申请').'-' . date("Y-m-d H:i:s", time());
        $xlsCell = [
            ['true_name', lang('收款人姓名')],
            ['account_type', lang('账户类型')],
            ['account_id', lang('账户')],
            ['qrcode', lang('收款二维码')],
            ['cash_fee', lang('提现金额')],
            ['handling_fee', lang('手续费')],
            ['pay_fee', lang('转账金额')],
            ['create_time', lang('创建时间')],
            ['check_status', lang('审核状态')],
            ['check_time', lang('审核时间')],
            ['check_reason', lang('拒绝原因')],
            ['cash_status', lang('转账状态')],
            ['cash_time', lang('转账时间')],
            ['account', lang('转账账户')],
            ['cash_time', lang('转账时间')],
        ];
        $excelData = array_values($_excelData);
        $this->exportExcel($xlsName, $xlsCell, $excelData);
    }

    public function account_type($type)
    {
        $data = ['1' => lang('微信'), '2' => lang('支付宝'), '3' => lang('银行卡')];
        return $data[$type];
    }

    public function check_status($status)
    {
        $data = ['0' => lang('待审核'), '1' => lang('通过'), '2' => lang('拒绝')];
        return $data[$status];
    }

    public function cash_status($staus)
    {
        $data = ['0' => lang('待转账'), '1' => lang('已转账'), '2' => lang('转账异常')];
        return $data[$staus];
    }
}
